﻿#ifndef ___PCLIB_S_SRLZ___
#define ___PCLIB_S_SRLZ___


#include "../m_core/m_core.hpp"
#include "s_json.hpp"

//序列化使用的内存分配函数定义
typedef long(WINAPI *_PCSrlzAllocateBuffer)(unsigned int ulSize, unsigned int ulFlags,    void** 	 lppvData);
typedef long(WINAPI *_PCSrlzAllocateMore  )(unsigned int ulSize, void* lpvOriginal,        void** 	 lppvData);
typedef long(WINAPI *_PCSrlzFreeBuffer    )(void* lppvData);


/**
*@brief  基于json对数据结构的描述，对某个数据类型进行序列化
*        
*/
class CPCSrlz : CPCNoCopyable
{
public:
    CPCSrlz(CPCJsonObject& desc, _PCSrlzAllocateBuffer allocBuffer, _PCSrlzAllocateMore allocMore, _PCSrlzFreeBuffer freeBuffer)
        : m_desc(desc)
        , m_allocBuffer(allocBuffer)
        , m_allocMore(allocMore)
        , m_freeBuffer(freeBuffer)
    {}

    CPCResult<std::string> Srlz(const void* src)
    {
        CPCResult<std::string> result;

        return result;
    }

    CPCResult<> UnSrlz(const char* src, size_t srcLen, void* dest)
    {
        CPCResult<> result;

        return result;
    }
  
private:
    CPCJsonObject&          m_desc;
    _PCSrlzAllocateBuffer   m_allocBuffer;
    _PCSrlzAllocateMore     m_allocMore;
    _PCSrlzFreeBuffer       m_freeBuffer;
};




#endif    //___PCLIB_S_SRLZ___
